<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Customer Home</title>
</head>
<body>
<form method="post" action="customers">
<h1>Customer Home</h1>

<div id="divMessage">
${message}
</div><br><br>
			<div id="divMain">
				<p>Welcome, <b>${currentuser}</b></p>
				<a href="javascript:pageFunction('VP');">View Profile</a> <br><br><br>
				<a href="javascript:pageFunction('CP');">Change Password</a> <br><br><br>
				<a href="javascript:pageFunction('BF');">Book Flight</a> <br><br><br>
				<a href="javascript:pageFunction('VF');">View Flight</a> <br><br><br>
			</div>

			<div id="divCP">
				<table>
		
				<tr><td>New Password: </td>
				<td><input type="password" name="newpassword" size="20" maxlength="20"/></td></tr>
				<tr><td>Re-enter New Password: </td>
				<td><input type="password" name="repassword" size="20" maxlength="20"/></td></tr>
				</table><br><br>
	
				<input id="changepassword" type="button" value="Change Password"/>	
			
			</div>

			<div id="div3">
			</div>

			<div id="div4">
			</div>

		<input id="pageVal" type="hidden" name="pageVal"/>
		<input id="submit" type="submit" name="submit" value="submit"/>


</form>

	<script language="JavaScript" type="text/JavaScript">
		
	$(window).load(function(){
		$("#submit").hide();
		if('${userSession}' ==  "" || '${userSession}' ==  null)
			self.location = "customerLogin.jsp";
		if('${error}' == "true" && '${divn}' == "CP")
			pageFunction('${divn}');
		else 
		{
			if('${divn}' == "VP")
				open("viewProfile.jsp","","width=900,height=400,scrollbars,resizable,toolbar,status");
			else if('${divn}' == "VF")
				open("viewFlights.jsp","","width=900,height=400,scrollbars,resizable,toolbar,status");
			$("div:not(#divMain)").hide();
		}
		$("#divMessage").show();
	});
	
	$("#changepassword").click(function(){
		if(!$("input[name=newpassword]").val())
			alert("Please enter New Password.");
		else if(!$("input[name=repassword]").val())
			alert("Please Re-enter New Password.");
		else if($("input[name=newpassword]").val() != $("input[name=repassword]").val())
			alert("New Password does not match.");
		else $("#submit").click();
	});
	
	function pageFunction(div)
	{
		$("#pageVal").val(div);
		if(div == "BF")
		{
			$("#submit").click();
		}
		else if(div == "VF")
		{
			$("#submit").click();
		}
		else if(div == "VP")
		{
			$("#submit").click();
		}
		else if(div == "CP")
		{
			$("div").hide();
			$("#divCP").show();
		}

		
	}

	</script>
	
</body>


</html>